package com.x.service.impl;

import com.x.dao.BookDao;
import com.x.service.BookService;

/**
 * ClassName: BookServiceImpl
 * Package: IntelliJ IDEA
 * Description:
 * Written by HanXu
 * Create 2024.08.31 16:17
 */
public class  BookServiceImpl implements BookService {
    //删除业务层中new方式创建的Dao对象
    //private BookDao bookDao = new BookDaoImpl();
    private BookDao bookDao;

    public void save(){
        System.out.println("Book Service save. ");
        bookDao.save();
    }

    /*
    //set方法DI注入依赖: 提供对应的set方法
    public void setBookDao(BookDao bookDao) {
        this.bookDao = bookDao;
    }*/

    //构造器实现DI注入依赖: 提供构造器传递对象参数
    public BookServiceImpl(BookDao bookDao) {
        this.bookDao = bookDao;
    }
}
